package com.zhuiYun.project.api.slideshow.service.Impl;

import com.zhuiYun.project.api.slideshow.entity.SlideShowEntity;
import com.zhuiYun.project.api.slideshow.entity.SlideShowEntityVO;
import com.zhuiYun.project.api.slideshow.mapper.SlideShowMapper;
import com.zhuiYun.project.api.slideshow.service.SlideShowService;
import com.zhuiYun.project.common.errorCode.CommonException;
import com.zhuiYun.project.common.errorCode.EmErrorCode;
import com.zhuiYun.project.common.response.CommonResult;
import com.zhuiYun.project.util.ObjectUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName:
 * @descriptions:
 * @Author: zq
 * @Date 2023/4/12 13:35
 */
@Service
public class SlideShowServiceImpl implements SlideShowService {
    @Resource
    SlideShowMapper slideShowMapper;

    /**
     * @description: pc轮播图管理index主页
     * @author: zq
     * @date: 2023/4/12 13:44
     * @param: []
     * @return: com.zhuiYun.project.common.response.CommonResult
    **/
    @Override
    public CommonResult slideShowByType() throws CommonException {
        List<SlideShowEntityVO> slideShowEntities = slideShowMapper.slideShowByType();
        if (ObjectUtils.isNotEmpty(slideShowEntities)){
            return CommonResult.ok(slideShowEntities);
        } else {
            return CommonResult.error(EmErrorCode.ID_NOT_OBJECT);
        }
    }

    /**
     * @description: pc轮播图管理商品分类页
     * @author: zq
     * @date: 2023/4/12 14:17
     * @param: []
     * @return: com.zhuiYun.project.common.response.CommonResult
    **/
    @Override
    public CommonResult slideShowByTypes() throws CommonException {
        List<SlideShowEntityVO> slideShowEntities = slideShowMapper.slideShowByTypes();
        if (ObjectUtils.isNotEmpty(slideShowEntities)){
            return CommonResult.ok(slideShowEntities);
        } else {
            return CommonResult.error(EmErrorCode.ID_NOT_OBJECT);
        }
    }

    /**
     * @description: pc轮播图管理DIY页
     * @author: zq
     * @date: 2023/4/12 14:28
     * @param: []
     * @return: com.zhuiYun.project.common.response.CommonResult
    **/
    @Override
    public CommonResult slideShowByTypeDiy() throws CommonException {
        List<SlideShowEntityVO> slideShowEntities = slideShowMapper.slideShowByTypeDiy();
        if (ObjectUtils.isNotEmpty(slideShowEntities)){
            return CommonResult.ok(slideShowEntities);
        } else {
            return CommonResult.error(EmErrorCode.ID_NOT_OBJECT);
        }
    }
}
